/*
 * @Author: DESKTOP-05FP536\Administrator 18368095041@163.com
 * @Date: 2025-01-26 17:53:55
 * @LastEditors: DESKTOP-05FP536\Administrator 18368095041@163.com
 * @LastEditTime: 2025-02-02 19:51:12
 * @FilePath: \vue3-admin\src\utils\json.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
export const replaceStringUndefined = (obj: unknown) => {
    if (obj === null || typeof obj !== 'object') {
        // 如果 obj 不是对象或者为 null，则直接返回
        return obj;
    }

    for (const key in obj) {
        if (Reflect.has(obj, key)) {
            const value = Reflect.get(obj, key);
            if (value === 'undefined') {
                Reflect.set(obj, key, undefined); // 将字符串 'undefined' 替换为 undefined
            } else if (typeof value === 'object') {
                // 递归处理嵌套对象
                replaceStringUndefined(value);
            }
        }
    }

    return obj;
};
